package org.study.config;

import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: jzhou
 * @date: 2025/7/5-10:13
 * @version: 1.0
 * @description:  <a href="https://docs.langchain4j.dev/get-started"> 知识出处 </a>
 */
@Configuration
public class LLMConfig {
    @Bean("qwen")
    public ChatModel chatModelQwen()
    {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("qwen-plus")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    /**
     * @Description: <a href="https://api-docs.deepseek.com/zh-cn/"> DeepSeek API 知识出处</a>
     * 多模型共存
     */

    @Bean("deepseek")
    public ChatModel chatModelDeepSeek()
    {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("deepseek-r1")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    // ==== 文生图模型
    /**
     https://docs.langchain4j.dev/tutorials/chat-and-language-models/#image-content
     */
    @Bean("qwen-vl")
    public ChatModel chatModelAlibaba(){
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("qwen-vl-max")
                //qwen-vl-max 是一个多模态大模型，支持图片和文本的结合输入，适用于视觉-语言任务。
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    /**
     * @Description: 测试通义万象来实现图片生成，
     * 官网说明：https://help.aliyun.com/zh/model-studio/text-to-image
     */
    @Bean
    public WanxImageModel wanxImageModel()
    {
        return WanxImageModel.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .modelName("wanx2.1-t2i-turbo") //图片生成 https://help.aliyun.com/zh/model-studio/text-to-image
                .build();
    }
}
